<p style="position:absolute;top:40%;width:100%;font-size:18px;text-align:center;">活动已结束</p>
<?php
exit;
session_start();
$cdnUrl='http://lin.mei94.com/hisense-card/';
 

//http://hisense.mei94.com/

include_once './c/config.php';
include 'jssdk.php';
$jssdk = new JSSDK($appId, $secret);
$signPackage = @$jssdk->GetSignPackage();
if (isset($_GET['op'])){
    $_SESSION['openid']=$_GET['op'];
}

if (isset($_SESSION['openid'])){
    $openid=$_SESSION['openid'];
}else{
    header('Location: http://hisense.mei94.com/');
    exit;
}

$mysqli = new mysqli($dbhost, $dbuser, $dbpwd, $dbName);
if (!$mysqli->set_charset("utf8")) {printf("Error loading character set utf8: %s\n", $mysqliTwo->error);}
$hasLing=false;
$query=$mysqli->query("select id from ucard where openid='".$openid."' limit 0, 1");
if($query->num_rows>0){
    $hasLing=true;
}
?><!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>品质家电 焕新盛典</title>
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1">
<style>
html,body{width:100%;font-size:12px;font-family:Helvetica,Tahoma, Arial, STXihei,Microsoft YaHei, Gotham, "Helvetica Neue", Helvetica, Arial, sans-serif;}
body{-webkit-overflow-scrolling: touch;overflow-scrolling: touch;overflow-y: scroll;}
body, div{padding:0px;margin:0px auto;max-width:750px;}
.weui-dialog{position:fixed;z-index:5000;width:80%;max-width:300px;top:50%;left:50%;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);background-color:#FFF;text-align:center;border-radius:3px;overflow:hidden}.weui-dialog__hd{padding:1.3em 1.6em .5em}.weui-dialog__title{font-weight:400;font-size:36px}.weui-dialog__bd{padding:0 1.6em .86em;min-height:40px;font-size:15px;line-height:1.3;word-wrap:break-word;word-break:break-all;color:#999}.weui-dialog__bd:first-child{padding:1.2em 20px .1em;color:#353535}.weui-dialog__ft{position:relative;line-height:48px;font-size:18px;display:-webkit-box;display:-webkit-flex;display:flex}.weui-dialog__ft:after{content:" ";position:absolute;left:0;top:0;right:0;height:1px;border-top:1px solid #D5D5D6;color:#D5D5D6;-webkit-transform-origin:0 0;transform-origin:0 0;-webkit-transform:scaleY(.5);transform:scaleY(.5)}.weui-dialog__btn{display:block;-webkit-box-flex:1;-webkit-flex:1;flex:1;color:#3CC51F;text-decoration:none;-webkit-tap-highlight-color:transparent;position:relative}.weui-dialog__btn:active{background-color:#EEE}.weui-dialog__btn:after{content:" ";position:absolute;left:0;top:0;width:1px;bottom:0;border-left:1px solid #D5D5D6;color:#D5D5D6;-webkit-transform-origin:0 0;transform-origin:0 0;-webkit-transform:scaleX(.5);transform:scaleX(.5)}.weui-dialog__btn:first-child:after{display:none}.weui-dialog__btn_default{color:#353535}.weui-dialog__btn_primary{color:#0BB20C}@media screen and (min-width:1024px){.weui-dialog{width:35%}}.weui-mask{position:fixed;z-index:1000;top:0;right:0;left:0;bottom:0;background:rgba(0,0,0,.6)}
.weui-mask_transparent{position:fixed;z-index:1000;top:0;right:0;left:0;bottom:0}
.js_dialog{display:none;}
-webkit-touch-callout:none;
-webkit-user-select:none;
html{-ms-touch-action:none;}
div,img{-webkit-tap-highlight-color:rgba(0,0,0,0);}
*{-webkit-text-size-adjust: none;}
.simg{position:absolute;display:block;}
a{text-decoration:none;}
.txt{position:absolute;text-indent:6px;color:#787c7f;font-size:13px;z-index:2;border:none;background:transparent;}
.txt::-webkit-input-placeholder{text-align:left;color:#a2a2a2;}
select{position:absolute;color:#787c7f;display:block;background:transparent;border:0px;text-indent:6px;font-size:13px;-webkit-appearance:none;}
.container{position:relative;width:100%;height:auto;}
.page{position:absolute;width:100%;height:100%;display:none;top:0;left:0;}
.home{position:absolute;width:100%;height:100%;top:0;left:0;opacity:0;}
.haitu{position:relative;width:100%;height:auto;margin:0;display:block;} 
.p2-biao, .p2-form, .p2-done{position:absolute;width:100%;left:0;}
#citybody{position:absolute;width:100%;}
.p2-bao{position:absolute;}
.home-qi, .home-arr{position:absolute;display:none;z-index:3;}
.hide{display:none;}
</style><script>var _hmt = _hmt || [];(function() {
  var hm = document.createElement("script");
  hm.src = "https://hm.baidu.com/hm.js?7497c824a97ab96a9c741b718076fe5b";
  var s = document.getElementsByTagName("script")[0]; 
  s.parentNode.insertBefore(hm, s);
})();</script></head><body>
<div class="container">
    <div class="home">
       <img class="home-qi" src="<?php echo $cdnUrl; ?>img/qi.png" />
       <img class="home-arr" src="<?php echo $cdnUrl; ?>img/arr.png" />
       <img class="haitu" src="<?php echo $cdnUrl; ?>img/home-1.jpg?v=4" />
       <img class="haitu" src="<?php echo $cdnUrl; ?>img/home-2.jpg?v=4" />
       <img class="haitu" src="<?php echo $cdnUrl; ?>img/home-3.jpg?v=4" />
       <img class="haitu" src="<?php echo $cdnUrl; ?>img/home-4.jpg?v=4" />
    </div>
    
    <div class="p2 page">
    
       <img class="haitu" src="<?php echo $cdnUrl; ?>img/p2-1.jpg?v=11" />
       <img class="haitu" src="<?php echo $cdnUrl; ?>img/p2-2.jpg?v=11" />
       <img class="haitu" src="<?php echo $cdnUrl; ?>img/p2-3.jpg?v=11" />   
       <img class="p2-form" src="<?php echo $cdnUrl; ?>img/form.png?v=14" /> 
       <img class="p2-done hide" src="<?php echo $cdnUrl; ?>img/done.png?v=11" /> 
      
       <div class="p2-biao">
          <input id="u-phone" class="txt" name="phone" type="number" placeholder="电话" />
          <input id="u-name" class="txt" name="name" type="text" placeholder="姓名" />
          <div id="citybody">
              <select class="prov" id="sheng"></select>
              <select class="city" id="shi"></select>
          </div>
          <input id="u-jia" class="txt" name="jia" type="text" placeholder="意向家电品类" />
          
          <img class="p2-yes simg" src="<?php echo $cdnUrl; ?>img/no.png" />
          <img class="p2-no simg" src="<?php echo $cdnUrl; ?>img/no.png" />
          <div class="p2-yes-click simg" data-id='yes'></div>
          <div class="p2-no-click simg" data-id='no'></div>   
          
          <div class="u-submit simg"></div>
       </div>
    
    </div>
    
    <div class="js_dialog">
       <div class="weui-mask"></div>
       <div class="weui-dialog">
                <div class="weui-dialog__bd weui-msg"></div>
                <div class="weui-dialog__ft">
                    <a href="javascript:;" class="weui-dialog__btn weui-dialog__btn_primary weui-btn">知道了</a>
                </div>
        </div>
     </div>
	  
</div>
<script src="http://mat1.gtimg.com/libs/jquery2/2.1.4/jquery2.min.js"></script>
<script src="<?php echo $cdnUrl ?>js/pxloader-images.min.js"></script>
<script src="<?php echo $cdnUrl ?>js/jquery.cityselect.js"></script>
<script src="http://res.wx.qq.com/open/js/jweixin-1.4.0.js"></script>
<script>
_h=h= Math.max(document.documentElement.clientHeight, window.innerHeight || 0);
var sWidth = parseInt((window.innerWidth > 0) ? window.innerWidth : screen.width);
if(sWidth>750){sWidth=750;}
var _rate=(sWidth/750);
var _img=['t1.jpg'];
var loader = new PxLoader();
for(var i=0; i<_img.length; i++){loader.addImage('<?php echo $cdnUrl; ?>img/'+_img[i]);}
loader.start();
loader.addCompletionListener(function(e){
	   $('.home').css({"opacity":1});
	   $(".home").fadeIn(); 
	   <?php if ($hasLing){ ?>
	   $('.p2-form, .p2-biao').hide();
  	   $('.p2-done').fadeIn();
	   <?php } ?>
});
var _ishui=''; //是否回收，no yes
$(function(){
	$('.container').width(sWidth);


	
	$('.home-qi').width(_rate*394).height(_rate*206).css({"top":_rate*4214, "left":0});
	$('.home-arr').width(_rate*324).height(_rate*327).css({"top":_rate*4314, "left":0});
 
	
	
	$('.p2-biao').height(_rate*800).css({"top":_rate*2130});

	$('.p2-form, .p2-done').height(_rate*1118).css({"top":_rate*1944});
	
	$('#u-phone').width(_rate*640).height(_rate*84).css({"top":0, "left":_rate*54,'line-height':_rate*84+'px'});
	$('#u-name').width(_rate*640).height(_rate*84).css({"top":_rate*108, "left":_rate*54,'line-height':_rate*84+'px'});
	$('#u-jia').width(_rate*640).height(_rate*84).css({"top":_rate*314, "left":_rate*54,'line-height':_rate*84+'px'});
	$('.p2-yes, .p2-no').width(_rate*52).height(_rate*41);
	$('.p2-yes').css({"top":_rate*432, "left":_rate*460});
	$('.p2-no').css({"top":_rate*432, "left":_rate*575});
	$('.p2-yes-click, .p2-no-click').width(_rate*100).height(_rate*80);
	$('.p2-yes-click').css({"top":_rate*426, "left":_rate*450});
	$('.p2-no-click').css({"top":_rate*426, "left":_rate*575}); 
	
	
	
	$('#citybody').height(_rate*84).css({"top":_rate*210});
	
	$('#sheng').width(_rate*280).height(_rate*84).css({"top":0, "left":_rate*54,'line-height':_rate*84+'px'});
	$('#shi').width(_rate*280).height(_rate*84).css({"top":0, "left":_rate*418,'line-height':_rate*84+'px'});

	$('.u-submit').width(_rate*660).height(_rate*120).css({"top":_rate*700, "left":_rate*40});

	$('.p2-bao').width(_rate*690).height(_rate*610).css({"top":_rate*1190, "left":_rate*30});

	
	
	
	$("#citybody").citySelect({
		nodata:"none",
		required:false
	}); 
	
	
	var _scrollCheck=true; 
    $(window).scroll(function () {
        if(false == _scrollCheck){return;}  
        var scrollTop = $(this).scrollTop();  
        var scrollHeight = $(document).height();  
        var windowHeight = $(this).height(); 
        var _this= $(this);
        if (scrollTop + windowHeight > scrollHeight-20) {  //滚动到底部执行事件  
                console.dir("bottom");
                window.setTimeout(function(){
                	$(".home-qi, .home-arr").fadeIn(); 
                    },400);
                _scrollCheck=false;
        }
        if (scrollTop == 0) {  //滚动到头部部执行事件  
            console.dir("top"); 
        }  
     });
    
    $(".home-qi, .home-arr").click(function(){
        $(".home").fadeOut(function(){
        	$(window).scrollTop(0);
            $(".p2").fadeIn();
        });
        
	 });  

    function _popmsg(msg){
    	$(".weui-msg").html(msg);$(".js_dialog").show();
    }
    $('.p2-yes-click, .p2-no-click').click(function(){
        var _id=$(this).attr("data-id");
        $(".p2-yes, .p2-no").attr("src", "<?php echo $cdnUrl; ?>img/no.png");
        if('yes' == _id){
        	_ishui='yes';
        	$(".p2-yes").attr("src", "<?php echo $cdnUrl; ?>img/yes.png");
        }else{
        	_ishui='no';
        	$(".p2-no").attr("src", "<?php echo $cdnUrl; ?>img/yes.png");
        }
    });
    $('.u-submit').click(function(){
        var _phone=$("#u-phone").val();
        var _name=$("#u-name").val();
        var _sheng=$("#sheng").val();
        var _shi=$("#shi").val();
        var _jia=$("#u-jia").val();
    	if('' == _phone){_popmsg('请您输入电话');return;} 
    	if('' == _name){_popmsg('请您输入姓名');return;}
    	if('' == _sheng){_popmsg('请您选择省');return;}
    	if('' == _shi){_popmsg('请您选择市');return;}
    	if('' == _jia){_popmsg('请您输入意向家电品类');return;}
    	if('' == _ishui){_popmsg('请选择是否需要上门收旧家电');return;}

    	$.post("./api/?c=shot2", {phone:_phone,name:_name,sheng:_sheng,shi:_shi,jia:_jia,ishui:_ishui}, function(data){
    		$('.p2-form, .p2-biao').hide();
        	$('.p2-done').fadeIn();
            if('go' == data.s){
           	 wx.addCard({
             	      cardList: [
             	        {
             	          cardId: data.c.cid,
             	          cardExt: '{"code": "'+data.c.code+'","openid": "<?php echo $openid; ?>", "timestamp": "'+data.c.timestamp+'", "signature":"'+data.c.sign+'"}'
             	        }
             	      ],
             	      success: function (res) {
             	         $.post("./api/?c=code1234", {code:res.cardList[0].code,thecode:data.c.code}, function(data){}, "json");
             	      },
             	      cancel: function (res) {
             	        //alert(JSON.stringify(res))
             	      }
             	    });
             }else{
               $(".weui-msg").html("您已领取过优惠券<br />请前往微信卡包中查看");
               $(".js_dialog").show();
               return;  
             }
         }, "json");

    	/**
    	$.post("./api/?c=u", {phone:_phone,name:_name,sheng:_sheng,shi:_shi,jia:_jia,ishui:_ishui}, function(data){
    		$('.p2-form, .p2-biao').hide();
    		$('.p2-done').fadeIn();
   	    }, "json");
    	 */

    }); 

   

    $(".js_dialog").click(function(){
        $(".js_dialog").hide();
	 });

    $('.p2-bao').click(function(){
        return;
    	$.post("./api/?c=shot2", {id:1}, function(data){
            if('go' == data.s){
           	 wx.addCard({
             	      cardList: [
             	        {
             	          cardId: data.c.cid,
             	          cardExt: '{"code": "'+data.c.code+'","openid": "<?php echo $openid; ?>", "timestamp": "'+data.c.timestamp+'", "signature":"'+data.c.sign+'"}'
             	        }
             	      ],
             	      success: function (res) {
             	         //alert(JSON.stringify(res))
             	         $.post("./api/?c=code1234", {code:res.cardList[0].code,thecode:data.c.code}, function(data){}, "json");
             	      },
             	      cancel: function (res) {
             	        //alert(JSON.stringify(res))
             	      }
             	    });
             }else{
               $(".weui-msg").html("您已领取过优惠券<br />请前往微信卡包中查看");
               $(".js_dialog").show();
               return;  
             
             }
         }, "json");
	 });	


    wx.config({
        appId: '<?php echo $signPackage["appId"];?>',timestamp: <?php echo $signPackage["timestamp"];?>,
        nonceStr: '<?php echo $signPackage["nonceStr"];?>',signature: '<?php echo $signPackage["signature"];?>',
        jsApiList: ['onMenuShareTimeline', 'onMenuShareAppMessage', 'onMenuShareQQ', 'onMenuShareWeibo', 'showMenuItems', 'hideMenuItems','addCard','chooseCard','openCard']
    });
    wx.ready(function () {
    		var _link='http://hisense.mei94.com/?id=share';
    		var _imgUrl='http://hisense.mei94.com/img/64.jpg?v=9';
    			wx.onMenuShareTimeline({title: '换新享补贴，带新有好礼，海信邀你焕新家电，让生活进阶！', link: _link, imgUrl: _imgUrl,success: function () {
    				//$.post("api/?c=share", {id:1}, function(data){}, "json");
    			},cancel: function () {
    			}});
    			wx.onMenuShareAppMessage({ title: '听说，你也想换家电？', desc: '换新享补贴，带新有好礼，海信邀你焕新家电，让生活进阶！',link: _link,imgUrl: _imgUrl, type: '', dataUrl: '', success: function () {
    				//$.post("api/?c=share", {id:1}, function(data){}, "json");
    			},cancel: function () { 
    			}});
    });
	 
	 
});
</script></body></html>